#include "logfulldialog.h"
#include "ui_logfulldialog.h"

LogFullDialog::LogFullDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::LogFullDialog)
{
    ui->setupUi(this);
    setLogLevelmsg(0,"#000000" , "追踪: ");
    setLogLevelmsg(1,"#000000", "调试: ");
    setLogLevelmsg(2,"#0000ff", "信息: ");
    setLogLevelmsg(3,"#ff6600", "追踪: ");
    setLogLevelmsg(4,"#ff3300", "警告: ");
    setLogLevelmsg(5,"#ff0000", "错误: ");
    setLogLevelmsg(6,"#ff0000", "评论: ");
}

LogFullDialog::~LogFullDialog()
{
    delete ui;
}

void LogFullDialog::setLogLevelmsg(int level, const QString & colorHex , const QString & str)
{
    logColorMap[level] = colorFrontA+colorHex+colorFrontB;
    logLeverStrMap[level] = str;
}

void LogFullDialog::update(int level, const char * msg)
{
    auto log = logColorMap[level] + logLeverStrMap[level] + msg +colorFrontEnd;
    ui->textEdit->append(log);
    ui->textEdit->ensureCursorVisible();
}
